Skip to main content link. Accesskey S
  • Help
  • HCL Logo
  • HCL Lotus Expeditor wiki
  • THIS WIKI IS READ-ONLY. Individual names altered for privacy purposes.
  • HCL forums and blogs
  • Home
  • Product Documentation
  • Community Articles
Search
Community Articles > Expeditor Client for Desktop > Sample: HTTP Communication
  • Share Show Menu▼
  • Subscribe Show Menu▼

Recent articles by this author

Sample: Toolbar and Menu Contributions

Expeditor user interface team best practices on toolbar and menu contributions

Sample: Component Properties

OverviewComponent properties allow developers to create code that at compile time has specific function but accepts flexible input at runtime. For example, a developer can create a component that uses a predefined component property to update the title tab's text within a composite ...

Sample: Multiuser Features

Overview When multiple users share the same workstation, the configuration is referred to as a multiuser installation. This means that a single Expeditor client exists and is shared among all users; however, each user has their own workspace containing configuration details specific to that ...

Sample: Starting Plugins

Overview By default, Eclipse plugins are lazy. Lazy is the technical term (located in the bundle's manifest) that means that plugins are started when a request is either directly made by the Platform to start the plugin or indirectly through class loading. For example, the latter case implies ...

Sample: HTTP Communication

Overview The enhanced HTTP client in Expeditor allows developers to quickly create code that requests data from remote servers over HTTP or HTTPS. The enhanced client wraps the standard Java URLConnectionclasses such that authenticated requests leverage the Accounts framework and HTTPS ...
Community articleSample: HTTP Communication
Added by ~Tip Desachekli | Edited by ~Tip Desachekli on May 4, 2011 | Version 2
  • Actions Show Menu▼
expanded Abstract
collapsed Abstract
No abstract provided.
Tags: samples
ShowTable of Contents
HideTable of Contents
  • 1 Overview
  • 2 URL Connections

Overview


The enhanced HTTP client in Expeditor allows developers to quickly create code that requests data from remote servers over HTTP or HTTPS. The enhanced client wraps the standard Java URLConnectionclasses such that authenticated requests leverage the Accounts framework and HTTPS requests provide a dialog to accept server certificates.

URL Connections


The following code very simply demonstrates the process of creating both HTTP and HTTPS connections and printing the returned content. To access authenticated content, simply create an account with a server value similar to those provided in the sample. By doing so, any requests made using the URLConnection classes will consult the Accounts framework to provide credentials along with the request. Again, the plugin's Activator class is used to start the code.

 public void start(BundleContext context) throws Exception {
	super.start(context);
	plugin = this;

	// two URLs to a web service running on WebSphere
	String HTTP_URL = "http://dpi-portvm.atlanta.ibm.com:10000/com.ibm.rcp.support.ws.remote/services/RemoteSystem";
	String HTTPS_URL = "https://dpi-portvm.atlanta.ibm.com:10002/com.ibm.rcp.support.ws.remote/services/RemoteSystem";

	URL httpUrl = new URL(HTTP_URL);
	URL httpsUrl = new URL(HTTPS_URL);

	// create HTTP and HTTPS connections
	HttpURLConnection httpConn = (HttpURLConnection) httpUrl
			.openConnection();
	HttpsURLConnection httpsConn = (HttpsURLConnection) httpsUrl
			.openConnection();

	URLConnection conns[] = { httpConn, httpsConn };

	// iterate over the connections and print the received content
	for (URLConnection conn : conns) {
		InputStream in = null;
		try {
			in = conn.getInputStream();

			BufferedReader br = new BufferedReader(
					new InputStreamReader(in));

			String line = null;
			while ((line = br.readLine()) != null) {
				System.out.println(line);
			}
		} finally {
			if (in != null) {
				in.close();
			}
		}
	}
}


  • Actions Show Menu▼


expanded Attachments (0)
collapsed Attachments (0)
Edit the article to add or modify attachments.
expanded Versions (2)
collapsed Versions (2)
Version Comparison     
VersionDateChanged by              Summary of changes
This version (2)May 4, 2011, 3:39:29 PM~Tip Desachekli  
1May 4, 2011, 3:23:05 PM~Tip Desachekli  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedAbout
  • HCL Software
  • HCL Digital Solutions community
  • HCL Software Support
  • BlogsDigital Solutions blog
  • Community LinkHCL Software forums and blogs
  • About HCL Software
  • Privacy
  • Accessibility